﻿using System;
using System.Collections.Generic;
using System.Linq;
using TeamRobot.Swtor;

namespace ItemDataGenerator
{
    public partial class ItemSourceWriter
    {
        private static readonly List<string> _setNames = new List<string>
        {
            "Combat Medic's",
            "Combat Tech's",
            "Eliminator's",
            "Supercommando's",
            "Vindicator's",
            "War Leader's",
            "Weaponmaster's",
            "Enforcer's",
            "Field Medic's",
            "Field Tech's",
            "Force-Master's",
            "Force-Mystic's",
            "Stalker's",
            "Survivor's",
        };

        private static readonly Dictionary<string, string> _setNameToToken = new Dictionary<string, string>
        {
            { "Combat Medic's", "Wargrade Tech" },
            { "Combat Tech's", "Wargrade Tech" },
            { "Eliminator's", "Wargrade Tech" },
            { "Supercommando's", "Wargrade Tech" },

            { "Vindicator's", "Frontline Force" },
            { "War Leader's", "Frontline Force" },
            { "Weaponmaster's", "Frontline Force" },

            { "Enforcer's", "Covert Tech" },
            { "Field Medic's", "Covert Tech" },
            { "Field Tech's", "Covert Tech" },

            { "Force-Master's", "Master Force" },
            { "Force-Mystic's", "Master Force" },
            { "Stalker's", "Master Force" },
            { "Survivor's", "Master Force" },
        };


        private static bool IsSetItem(Item item)
        {
            if (item.Quality == Quality.Prototype && item.ItemLevel == 56 && item.Name.StartsWith("Recruit"))
                return true;

            if ((item.ItemLevel == 58 || item.ItemLevel == 61) && (item.Name.StartsWith("War Hero") || item.Name.StartsWith("Battlemaster")))
                return true;

            if (item.Quality != Quality.Artifact)
                return false;

            if (item.ItemLevel == 51 || item.ItemLevel == 56 || item.ItemLevel == 58)
            {
                if (_setNames.Any(s => item.Name.IndexOf(s) != -1))
                    return true;
                else if (item.Slot == ItemSlot.Relic && (item.Name.StartsWith("Battlemaster") || item.Name.StartsWith("Champion")))
                    return true;
            }
            else if (item.ItemLevel == 61)
            {
                if (item.Name.StartsWith("Black Hole") || item.Name.StartsWith("War Hero") || item.Name.StartsWith("Campaign"))
                    return true;
            }
            return false;
        }

        /// <summary>
        /// Adds sources for set items.
        /// </summary>
        /// <param name="items"></param>
        /// <param name="sources"></param>
        private void GenerateSetItemSources(List<Item> items, Dictionary<int, List<ItemSource>> sources)
        {
            // this might not be necessary anymore... but prevents duplicating the source if an item appears in the data twice
            HashSet<int> doneItems = new HashSet<int>();

            // items with well-recognized names that we can match to costs
            foreach (Item item in items.Where(i => IsSetItem(i)))
            {
                if (doneItems.Contains(item.Id)) continue;
                doneItems.Add(item.Id);

                string[] words = item.Name.Split(' ');

                switch (words[0])
                {
                    case "Centurion":
                        AddCenturionSource(item, sources);
                        break;
                    case "Champion":
                        AddChampionSource(item, sources);
                        break;
                    case "Battlemaster":
                        AddBattlemasterSource(item, sources);
                        break;
                    case "Tionese":
                        AddTioneseSource(item, sources);
                        break;
                    case "Columi":
                        AddColumiSource(item, sources);
                        break;
                    case "Rakata":
                        AddRakataSource(item, sources);
                        break;
                    case "Energized":
                        AddEnergizedSource(item, sources);
                        break;
                    case "Xenotech":
                        AddXenotechSource(item, sources);
                        break;
                    case "Exotech":
                        AddExotechSource(item, sources);
                        break;
                    case "Black":
                        if (item.Name.Contains("MK-1"))
                            AddBlackHoleSource(item, sources);
                        else if (item.Name.Contains("MK-2") || item.Name.Contains("MK-3"))
                            AddBlackHoleMk3Source(item, sources);
                        break;
                    case "War":
                        if (words[words.Length - 1] == "(Rated)")
                            AddWarHeroRatedSource(item, sources);
                        else
                            AddWarHeroSource(item, sources);
                        break;
                    case "Recruit":
                        AddRecruitSource(item, sources);
                        break;
                    case "Campaign":
                        AddCampaignSource(item, sources);
                        break;
                }
            }

            // special cases
            AddSpecialSetSourcesByName(items, sources);
        }

        private void AddCenturionSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (item.Slot.HasValue)
            {
                switch (GetBetterSlot(item))
                {
                    case ItemSlot.Helm:
                    case ItemSlot.Chest:
                    case ItemSlot.Hands:
                    case ItemSlot.Legs:
                    case ItemSlot.Foot:
                    case ItemSlot.Belt:
                    case ItemSlot.Wrist:
                    case ItemSlot.MainHand:
                    case ItemSlot.OffHand:
                    case ItemSlot.Implant:
                    case ItemSlot.Ear:
                    case ItemSlot.Relic:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "No longer obtainable",
                        });
                        break;
                }
            }
        }

        private void AddChampionSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (item.Slot.HasValue)
            {
                switch (GetBetterSlot(item))
                {
                    case ItemSlot.Helm:
                    case ItemSlot.Chest:
                    case ItemSlot.Hands:
                    case ItemSlot.Legs:
                    case ItemSlot.Foot:
                    case ItemSlot.Belt:
                    case ItemSlot.Wrist:
                    case ItemSlot.MainHand:
                    case ItemSlot.OffHand:
                    case ItemSlot.Implant:
                    case ItemSlot.Ear:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "No longer obtainable",
                        });
                        break;
                    case ItemSlot.Relic:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Credits",
                            Cost = "11300",
                        });
                        break;
                }
            }
        }

        private void AddBattlemasterSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (item.Slot.HasValue)
            {
                if (item.HasRecipe == true)
                {
                    string boxName = GetPvpBoxName(item);
                    if (boxName != null)
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = " - 50k Credits",
                            Cost = boxName
                        });
                    return;
                }

                switch (GetBetterSlot(item))
                {
                    case ItemSlot.Helm:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "1075",
                        });
                        break;
                    case ItemSlot.Chest:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "1425",
                        });
                        break;
                    case ItemSlot.Hands:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "875",
                        });
                        break;
                    case ItemSlot.Legs:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "975",
                        });
                        break;
                    case ItemSlot.Foot:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "875",
                        });
                        break;
                    case ItemSlot.Belt:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "625",
                        });
                        break;
                    case ItemSlot.Wrist:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "550",
                        });
                        break;
                    case ItemSlot.MainHand:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "1550",
                        });
                        break;
                    case ItemSlot.OffHand:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "1550",
                        });
                        break;
                    case ItemSlot.Implant:
                    case ItemSlot.Ear:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "625",
                        });
                        break;
                    case ItemSlot.Relic:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Pvp,
                            Currency = "Warzone Commendations",
                            Cost = "550",
                        });
                        break;
                }
            }
        }

        private string GetPvpBoxName(Item item)
        {
            string token = _setNameToToken.Keys.FirstOrDefault(x => item.Name.Contains(x));
            if (token != null)
            {
                int pos = item.Name.IndexOf(token);
                bool isRated = item.Name.EndsWith("(Rated)");
                return item.Name.Substring(0, pos) + token + " Schematic Box" + (isRated ? " (Rated)" : "");
            }
            else
                return null;
        }

        private void AddTioneseSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "22 Tionese Commendations and 16 Tionese Crystals",
                    });
                    break;

                case ItemSlot.Belt:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Black Talon",
                        Npc = "GXR-5 Sabotage Droid",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Esseles",
                        Npc = "Ironfist",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Foundry",
                        Npc = "Burrower Matriarch",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Maelstrom Prison",
                        Npc = "Ancient Maelstrom Flayer",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Gharj"
                    });
                    break;

                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Directive 7",
                        Npc = "Interrogator",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Battle of Ilum",
                        Npc = "Velasu Graege and Drinda-Zel",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Ancient Pylons"
                    });
                    break;

                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The False Emperor",
                        Npc = "Jindo Krey",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "18 Tionese Commendations and 13 Tionese Crystals",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "22 Tionese Commendations and 16 Tionese Crystals",
                    });
                    break;

                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "18 Tionese Commendations and 13 Tionese Crystals",
                    });
                    break;

                case ItemSlot.Implant:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The False Emperor",
                        Npc = "Sith Entity",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Boarding Party",
                        Npc = "Chief Engineer Kels",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Ear:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Black Talon",
                        Npc = "GXR-7 Command Droid",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Esseles",
                        Npc = "ISS-994 Power Droid",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Battle of Ilum",
                        Npc = "Guid Patriarch",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.MainHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "41 Tionese Commendations and 28 Tionese Crystals",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The False Emperor",
                        Npc = "HK-47",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Soa",
                    });
                    break;

                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "14 Tionese Commendations and 9 Tionese Crystals",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Foundry",
                        Npc = "HK-47",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Maelstrom Prison",
                        Npc = "Lord Vanithrast",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;
            }
        }

        private void AddColumiSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "67 Columi Commendations",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Kaon Under Siege",
                        Npc = "Commander Lk'Graagth",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Bonethrasher",
                    });
                    break;

                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "67 Columi Commendations",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The False Emperor",
                        Npc = "Darth Malgus",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Soa",
                    });
                    break;

                case ItemSlot.Belt:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Gharj",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Jarg and Sorno",
                    });
                    break;

                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Black Talon",
                        Npc = "Yadira Ban",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Esseles",
                        Npc = "Vokk",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Ancient Pylons",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Foreman Crusher",
                    });
                    break;

                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "56 Columi Commendations",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Boarding Party",
                        Npc = "Commander Jorlund",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Taral V",
                        Npc = "Ripper",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Annihilation Droid XRR-3",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "67 Columi Commendations",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Directive 7",
                        Npc = "Mentor",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Lost Island",
                        Npc = "Project Sav-Rak",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Ancient Pylons",
                    });
                    break;

                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "56 Columi Commendations",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Foundry",
                        Npc = "Revan",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Maelstrom Prison",
                        Npc = "Grand Moff Kilran",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Lost Island",
                        Npc = "LR-5 Sentinel Droid",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Infernal Council",
                    });
                    break;

                case ItemSlot.Implant:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Gharj",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.MainHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Lost Island",
                        Npc = "Doctor Lorrick",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Karagga the Unyielding",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Soa",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Battle of Ilum",
                        Npc = "Darth Serevin",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Gharj",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Jarg and Sorno",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;
            }
        }

        private void AddRakataSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Warlord Kephess",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Bonethrasher",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Lost Island",
                        Npc = "Doctor Lorrick",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Zorn and Toth",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Soa",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Belt:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Firebrand and Stormcaller",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Jarg and Sorno",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Zorn and Toth",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Foreman Crusher",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Colonel Vorgath",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Annihilation Droid XRR-3",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Colonel Vorgath",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Ancient Pylons",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Firebrand and Stormcaller",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Infernal Council",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Implant:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "120 Daily Commendations",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Zorn and Toth",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Colonel Vorgath",
                    });
                    break;

                case ItemSlot.Ear:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Currency = "120 Daily Commendations",
                    });
                    break;

                case ItemSlot.MainHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Warlord Kephess",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Karagga the Unyielding",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Explosive Conflict",
                        Npc = "Firebrand and Stormcaller",
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Gharj",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;
            }
        }

        private void AddEnergizedSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Battle of Ilum",
                        Npc = "Krel Thak",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Annihilation Droid XRR-3",
                    });
                    break;

                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Directive 7",
                        Npc = "Bulwark",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Black Talon",
                        Npc = "Commander Ghuli",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Esseles",
                        Npc = "ISS-7 Guardian Battle Droid",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "The Foundry",
                        Npc = "The Foundry Guardian",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Maelstrom Prison",
                        Npc = "Colonel Daksh",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Boarding Party",
                        Npc = "Sakan Do'nair",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Taral V",
                        Npc = "",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;
            }
        }

        private void AddXenotechSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Kaon Under Siege",
                        Npc = "Waves of Rakghoul",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Bonethrasher",
                    });
                    break;

                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Karagga the Unyielding",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Foreman Crusher",
                    });
                    break;

                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "G4-B3 Heavy Fabricator",
                    });
                    break;

                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Jarg and Sorno",
                    });
                    break;

                case ItemSlot.Belt:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Flashpoint,
                        Zone = "Kaon Under Siege",
                        Npc = "KR-82 Expulser",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;
            }
        }

        private void AddExotechSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "The Eternity Vault",
                        Npc = "Annihilation Droid XRR-3",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Karagga the Unyielding",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Foreman Crusher",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "Bonethrasher",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;

                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "Karagga's Palace",
                        Npc = "G4-B3 Heavy Fabricator",
                        Difficulty = ZoneDifficulty.Hard,
                    });
                    break;
            }
        }

        private void AddBlackHoleSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (item.HasRecipe == true) return;
            if (!item.Slot.HasValue) return;

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Zone = "Fleet",
                        Currency = "Black Hole Commendations",
                        Cost = "60",
                    });
                    break;

                case ItemSlot.Belt:
                case ItemSlot.Implant:
                case ItemSlot.Ear:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Zone = "Fleet",
                        Currency = "Black Hole Commendations",
                        Cost = "35",
                    });
                    break;

                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Zone = "Fleet",
                        Currency = "Black Hole Commendations",
                        Cost = "30",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Zone = "Fleet",
                        Currency = "Black Hole Commendations",
                        Cost = "55",
                    });
                    break;

                case ItemSlot.Foot:
                case ItemSlot.Hands:
                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Commendation,
                        Zone = "Fleet",
                        Currency = "Black Hole Commendations",
                        Cost = "50",
                    });
                    break;
            }
        }

        private void AddBlackHoleMk3Source(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (item.HasRecipe == true) return;
            if (!item.Slot.HasValue) return;

            AddSource(item, sources, new ItemSource
            {
                SourceType = SourceType.Operation,
                Zone = "Explosive Conflict",
                Npc = "Warlord Kephess",
            });
            AddSource(item, sources, new ItemSource
            {
                SourceType = SourceType.Operation,
                Zone = "Explosive Conflict",
                Npc = "Zorn and Toth",
                Difficulty = ZoneDifficulty.Hard,
            });
            AddSource(item, sources, new ItemSource
            {
                SourceType = SourceType.Operation,
                Zone = "Explosive Conflict",
                Npc = "Firebrand and Stormcaller",
                Difficulty = ZoneDifficulty.Hard,
            });
            AddSource(item, sources, new ItemSource
            {
                SourceType = SourceType.Operation,
                Zone = "Explosive Conflict",
                Npc = "Colonel Vorgath",
                Difficulty = ZoneDifficulty.Hard,
            });
            AddSource(item, sources, new ItemSource
            {
                SourceType = SourceType.Operation,
                Zone = "Explosive Conflict",
                Npc = "Warlord Kephess",
                Difficulty = ZoneDifficulty.Hard,
            });
        }

        private void AddWarHeroSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            if (item.HasRecipe == true)
            {
                string boxName = GetPvpBoxName(item);
                if (boxName != null)
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Currency = " - 50k Credits",
                        Cost = boxName
                    });
                return;
            }

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 2425",
                    });
                    break;
                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 3200",
                    });
                    break;

                case ItemSlot.Belt:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 1425",
                    });
                    break;

                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 1250",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 2225",
                    });
                    break;

                case ItemSlot.Foot:
                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 2000",
                    });
                    break;

                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 3475",
                    });
                    break;

                case ItemSlot.MainHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Battlemaster Item + 3475",
                    });
                    break;

                case ItemSlot.Implant:
                case ItemSlot.Ear:
                case ItemSlot.Relic:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Warzone Commendations",
                        Cost = "1425 Ranked Warzone Commendations + 200",
                    });
                    break;
            }
        }

        private void AddWarHeroRatedSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;

            if (item.HasRecipe == true)
            {
                string boxName = GetPvpBoxName(item);
                if (boxName != null)
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Currency = " - 50k Credits",
                        Cost = boxName
                    });
                return;
            }

            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "285",
                    });
                    break;
                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "640",
                    });
                    break;

                case ItemSlot.Belt:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Base Item + 285",
                    });
                    break;

                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "Base Item + 250",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "445",
                    });
                    break;

                case ItemSlot.Foot:
                case ItemSlot.Hands:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Ranked Warzone Commendations",
                        Cost = "400",
                    });
                    break;
            }
        }

        private void AddRecruitSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (!item.Slot.HasValue) return;
            switch (GetBetterSlot(item))
            {
                case ItemSlot.Helm:
                case ItemSlot.Chest:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "31700",
                    });
                    break;

                case ItemSlot.Belt:
                case ItemSlot.Wrist:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "20500",
                    });
                    break;

                case ItemSlot.Hands:
                case ItemSlot.Foot:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "26200",
                    });
                    break;

                case ItemSlot.Legs:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "31700",
                    });
                    break;

                case ItemSlot.MainHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "38600",
                    });
                    break;

                case ItemSlot.OffHand:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "19300",
                    });
                    break;

                case ItemSlot.Ear:
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Pvp,
                        Zone = "Fleet",
                        Currency = "Credits",
                        Cost = "17000",
                    });
                    break;
            }
        }

        private void AddCampaignSource(Item item, Dictionary<int, List<ItemSource>> sources)
        {
            if (item.HasRecipe == true) return;

            if (item.Slot == ItemSlot.Relic)
            {
                AddSource(item, sources, new ItemSource
                {
                    SourceType = SourceType.Commendation,
                    Cost = "200",
                    Currency = "Daily Commendations"
                });

                AddSource(item, sources, new ItemSource
                {
                    SourceType = SourceType.Operation,
                    Zone = "Explosive Conflict",
                    Npc = "Warlord Kephess",
                });
                AddSource(item, sources, new ItemSource
                {
                    SourceType = SourceType.Operation,
                    Zone = "Explosive Conflict",
                    Npc = "Zorn and Toth",
                    Difficulty = ZoneDifficulty.Hard,
                });
                AddSource(item, sources, new ItemSource
                {
                    SourceType = SourceType.Operation,
                    Zone = "Explosive Conflict",
                    Npc = "Firebrand and Stormcaller",
                    Difficulty = ZoneDifficulty.Hard,
                });
                AddSource(item, sources, new ItemSource
                {
                    SourceType = SourceType.Operation,
                    Zone = "Explosive Conflict",
                    Npc = "Colonel Vorgath",
                    Difficulty = ZoneDifficulty.Hard,
                });
                AddSource(item, sources, new ItemSource
                {
                    SourceType = SourceType.Operation,
                    Zone = "Explosive Conflict",
                    Npc = "Warlord Kephess",
                    Difficulty = ZoneDifficulty.Hard,
                });
            }
            else
            {
                string token = GetCampaignTokenName(item);
                if (token != null)
                    AddSource(item, sources, new ItemSource
                    {
                        SourceType = SourceType.Operation,
                        Zone = "1 " + token
                    });

                if (!item.Slot.HasValue) return;
                switch (GetBetterSlot(item))
                {
                    case ItemSlot.Helm:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Warlord Kephess",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.Chest:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Colonel Vorgath",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.Legs:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Zorn and Toth",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.Hands:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Colonel Vorgath",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.Belt:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Firebrand and Stormcaller",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.Wrist:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Zorn and Toth",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.MainHand:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Warlord Kephess",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                    case ItemSlot.OffHand:
                        AddSource(item, sources, new ItemSource
                        {
                            SourceType = SourceType.Operation,
                            Zone = "Explosive Conflict",
                            Npc = "Firebrand and Stormcaller",
                            Difficulty = ZoneDifficulty.Hard,
                        });
                        break;

                }
            }
        }

        private static string GetCampaignTokenName(Item item)
        {
            if (!item.Slot.HasValue)
                return null;

            ItemSlot slot = GetBetterSlot(item);
            switch (slot)
            {
                case ItemSlot.Belt:
                    return "Unassembled Campaign Belt";
                case ItemSlot.Helm:
                    return "Unassembled Campaign Headgear";
                case ItemSlot.Chest:
                    return "Unassembled Campaign Armor";
                case ItemSlot.Foot:
                    return "Unassembled Campaign Boots";
                case ItemSlot.Hands:
                    return "Unassembled Campaign Gloves";
                case ItemSlot.Wrist:
                    return "Unassembled Campaign Bracers";
                case ItemSlot.Legs:
                    return "Unassembled Campaign Greaves";
                case ItemSlot.MainHand:
                    return "Unassembled Campaign Mainhand Weapon";
                case ItemSlot.OffHand:
                    return "Unassembled Campaign Offhand Weapon";
                default:
                    return null;
            }
        }

        /// <summary>
        /// Some special cases that we look up by name.
        /// </summary>
        /// <param name="items"></param>
        /// <param name="sources"></param>
        private void AddSpecialSetSourcesByName(List<Item> items, Dictionary<int, List<ItemSource>> sources)
        {
            // special cases
            foreach (Item item in items)
            {
                if (item.Quality != Quality.Artifact) continue;

                if (item.Slot == ItemSlot.Relic)
                {
                    switch (item.Name)
                    {
                        // centurion pvp relics don't have "centurion" in the name
                        case "Relic of Boundless Ages":
                        case "Relic of Forbidden Secrets":
                        case "Relic of Imperiling Serenity":
                        case "Relic of the Primeval Fatesealer":
                        case "Relic of the Shrouded Crusader":
                            AddSource(item, sources, new ItemSource
                            {
                                SourceType = SourceType.Pvp,
                                Currency = "Centurion Commendations",
                                Cost = "14",
                            });
                            continue;
                    }
                }
                else
                {
                    if (item.ItemLevel == 51)
                    {
                        switch (item.Name)
                        {
                            // tionese weapons, all have special names
                            case "Hatred":
                            case "Justice":
                            case "Ludo Kressh's War Sword":
                            case "Qel-Droma Ancestral Blade":
                            case "Master Chamma's Lightsaber":
                            case "Temptation":
                            case "Dantooine's Last Hope":
                            case "Darth Bandon's Double-Bladed Lightsaber":
                            case "Last Bastion":
                            case "Warstaff of the Mandalorian Champion":
                            case "Fast Credits":
                            case "Professional's Choice":
                            case "The Glowing Gun":
                            case "Longshot":
                            case "The Unslung Hero":
                            case "Taung Blaster":
                            case "Chrome-Plated Killer":
                            case "Force-Multiplier Five":
                            case "The Hurricane":
                            case "Comet Strike":
                            case "Triumph":
                            case "Lightlance Rifle":
                                AddTioneseSource(item, sources);
                                continue;

                            // tionese mh drops with ilvl56 color crystals
                            case "Guiding Light":
                            case "Honor":
                            case "Saber of the Eternal Grandmaster":
                            case "The Bulwark":
                            case "The Unstoppable Force":
                            case "Kaelynn's Grace":
                            case "Thelanthra's Wrath":
                            case "Casualty":
                            case "Champion's Decree":
                            case "Ki-Lu's Saberstaff":
                            case "Polesaber of Quintessential Defense":
                            case "Zarlov's Electrostaff":
                            case "Hypersonic Blaster":
                            case "Silence":
                            case "The Blast Ward":
                            case "Guile":
                            case "The Specialist":
                            case "Blaststorm":
                            case "The Pacifist":
                            case "Hard Hitter":
                            case "Two-Tonne Striker":
                            case "Blackstar Squad Special":
                            case "Ruin":
                            case "The Prowler":
                                AddSource(item, sources, new ItemSource
                                {
                                    SourceType = SourceType.Flashpoint,
                                    Zone = "Kaon Under Siege",
                                    Npc = "Rakghoul Behemoth",
                                    Difficulty = ZoneDifficulty.Hard,
                                });
                                continue;

                            // tionese offhands
                            case "Fear":
                            case "Mercy":
                            case "Cyberlink Freefire":
                            case "The Equalizer":
                            case "Cipher Twenty's Energy Blade":
                            case "Edge":
                            case "Kneecapper":
                            case "Menace":
                            case "Negotiator":
                                AddTioneseSource(item, sources);
                                continue;

                            // tionese offhand drops
                            case "Strife":
                            case "Zeal":
                            case "The Invigorator":
                            case "The Sleeper":
                            case "Sharp and Ready":
                            case "Yago's Kiss":
                            case "The Stinger":
                            case "The Adjudicator":
                            case "The Cudgel":
                                AddSource(item, sources, new ItemSource
                                {
                                    SourceType = SourceType.Operation,
                                    Zone = "Karagga's Palace",
                                    Npc = "Jarg and Sorno",
                                });
                                continue;
                        }
                    }
                    else if (item.ItemLevel == 56)
                    {
                        switch (item.Name)
                        {
                            // columi weapons
                            case "Punisher":
                            case "Soresu's Razor":
                            case "The Stalwart Arm":
                            case "Draay's Legacy":
                            case "Terentatek's Bane":
                            case "The Debilitator":
                            case "The Shadowsaber":
                            case "Colicoid Prototype \"Venom\"":
                            case "Early Retirement":
                            case "Fury-7 Prototype Blaster":
                            case "Shadow Fist Assault Rifle":
                            case "The Linecutter":
                            case "Grace":
                            case "Quickshot":
                            case "Modified Vehicular Assault Weapon":
                            case "The Trench Burner":
                            case "Stonewall":
                            case "The Medal Pinner":
                            case "No Regret":
                                AddColumiSource(item, sources);
                                continue;

                            // columi offhands
                            case "Redeemer":
                            case "The Fall of Atris":
                            case "Davik Kang's Sidearm":
                            case "Neo-Crusader's Notchcutter":
                            case "Project Claw":
                            case "The Cloaked Eliminator":
                            case "Crossfire Cara's Little Helper":
                            case "Persuader":
                            case "Vertical City Suckerpunch":
                                AddColumiSource(item, sources);
                                continue;
                        }
                    }
                    else if (item.ItemLevel == 58)
                    {
                        switch (item.Name)
                        {
                            // rakata weapons
                            case "Battlemaster's Striker":
                            case "Darth Sion's Lightsaber":
                            case "Sword of Ieldis":
                            case "The Heart of Ragnos":
                            case "The Indomitable":
                            case "Echo of XoXaan":
                            case "Jolee Bindo's Lightsaber":
                            case "Bastila Shan's Double-Bladed Lightsaber":
                            case "Battlestaff of the Echani Duelmaster":
                            case "Blood of Korriban":
                            case "Exar Kun's Double-Bladed Lightsaber":
                            case "Starshard":
                            case "Precision Strike":
                            case "Quiet":
                            case "The Lesser's Legacy":
                            case "Project STORM Rifle":
                            case "Scorekeeper":
                            case "Blackhand":
                            case "Old Ironsights":
                            case "Project STORM Cannon":
                            case "The Firestorm":
                            case "Linebreaker":
                            case "Lucky's Last Stand":
                            case "The Headhunter":
                                AddRakataSource(item, sources);
                                continue;

                            // rakata offhands
                            case "Battlemaster's Guard":
                            case "The Oath of Ragnos":
                            case "Overkill":
                            case "Peace":
                            case "Ghost":
                            case "Ripper Nine":
                            case "Ace in the Hole":
                            case "Disaster Insurance":
                            case "Eradicator":
                                AddRakataSource(item, sources);
                                continue;
                        }
                    }
                }


            }
        }


    }
}
